home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / dev / c / cxref_1_4a.lha / cpp / config-cpp < prev    next >
Text File  |  1996-11-16  |  4KB  |  153 lines

  1. #!/bin/sh
  2. #$Header: /home/amb/cxref/cpp/RCS/config-cpp 1.3 1996/11/16 16:03:01 amb Exp $
  3. #
  4. # C Cross Referencing & Documentation tool. Version 1.3
  5. #
  6. # Automatic cxref-cpp Configuration program.
  7. #
  8. # Written by Andrew M. Bishop
  9. #
  10. # This file Copyright 1995,96 Andrew M. Bishop
  11. # It may be distributed under the GNU Public License, version 2, or
  12. # any higher version.  See section COPYING of the GNU Public license
  13. # for conditions under which this file may be redistributed.
  14. #
  15.  
  16. # Create the Makefile.cpp header.
  17.  
  18. cat > Makefile.cpp << End-Of-Header
  19. #
  20. # C Cross Referencing & Documentation tool. Version 1.3
  21. #
  22. # CPP Configuration Makefile.
  23. #
  24. # Generated by config-cpp
  25. #
  26. # This file Copyright 1995,96 Andrew M. Bishop
  27. # It may be distributed under the GNU Public License, version 2, or
  28. # any higher version.  See section COPYING of the GNU Public license
  29. # for conditions under which this file may be redistributed.
  30. #
  31. End-Of-Header
  32.  
  33.  
  34. # Check that the C compiler is gcc
  35.  
  36. ok_gcc=yes
  37.  
  38. [ $CC ] || CC=gcc
  39.  
  40. echo Checking C compiler CC = $CC for compatability
  41.  
  42. if hash $CC 2> /dev/null ; then
  43.     $CC -E -v - < /dev/null 2> /tmp/config-cpp.$$ > /dev/null
  44.     ident=`egrep '^GNU CPP' /tmp/config-cpp.$$`
  45.  
  46.     if [ "$ident" ]; then
  47.         echo '        ' Yes ... $CC looks like GNU C \'$ident\'
  48.     else
  49.         echo '        ' No ... $CC does not look like GNU C
  50.         ok_gcc=no
  51.     fi
  52. else
  53.     echo '        ' Error ... Cannot find command $CC
  54.     ok_gcc=no
  55. fi
  56.  
  57.  
  58. # Work out the gcc predefined definitions to compile in.
  59.  
  60. echo Working out C compiler built in predefines
  61.  
  62. cat >> Makefile.cpp << End-Of-Predefines
  63.  
  64. # The predefined macros and answers to questions
  65. # e.g PREDEFINES = -D__GNUC__=2 -D__GNUC_MINOR__=6 -Dunix -D__unix__ -D__unix -Asystem(unix)
  66.  
  67. End-Of-Predefines
  68.  
  69. if [ $ok_gcc = yes ]; then
  70.     echo PREDEFINES = `egrep -e -lang-c /tmp/config-cpp.$$ | tr ' ' '\012' | egrep -e '^-[AD]' | tr '\012' ' '` >> Makefile.cpp
  71. else
  72.     echo PREDEFINES = '' >> Makefile.cpp
  73. fi
  74.  
  75.  
  76. # Work out the gcc predefined include directories to compile in.
  77.  
  78. echo Working out C compiler built in include paths
  79.  
  80. cat >> Makefile.cpp << End-Of-Search-Includes
  81.  
  82. # The predefined include search directories
  83.  
  84. End-Of-Search-Includes
  85.  
  86. if [ $ok_gcc = yes ]; then
  87.     awk '/include <.+> search/,/End of search/ {if(i>0 && i<4)printf("INCLUDE_DIR%d = %s\n",i,$1);i++}' /tmp/config-cpp.$$ >> Makefile.cpp
  88. else
  89.     awk 'BEGIN{for(i=1;i<4;i++)printf("INCLUDE_DIR%d = \n",i);i++}' /dev/null >> Makefile.cpp
  90. fi
  91.  
  92.  
  93. # A check of whether we need SVR4 string functions.
  94.  
  95. echo Checking if the system has the bzero function
  96.  
  97. svr4_strings=no
  98.  
  99. cat > test-svr4.c << End-Of-SVR4-String-Test-Program
  100.  
  101. int main()
  102. {
  103.  bzero(0,0);
  104. }
  105.  
  106. End-Of-SVR4-String-Test-Program
  107.  
  108. $CC test-svr4.c -o test-svr4 2> /dev/null || svr4_strings=yes
  109.  
  110. rm -f test-svr4.c test-svr4
  111.  
  112. cat >> Makefile.cpp << End-Of-SVR4-Strings
  113.  
  114. # Set if replacements for bzero, bcmp, bcopy and index, rindex are needed
  115.  
  116. End-Of-SVR4-Strings
  117.  
  118. if [ $svr4_strings = yes ]; then
  119.     echo '        ' No ... the bzero function is not present
  120.     echo SVR4_STRINGS = 1 >> Makefile.cpp
  121. else
  122.     echo '        ' Yes ... the bzero function is present
  123.     echo SVR4_STRINGS = 0 >> Makefile.cpp
  124. fi
  125.  
  126. # A flag to indicate the the configuration status.
  127.  
  128. cat >> Makefile.cpp << End-Of-Configuration-Status
  129.  
  130. # The status of the configuration
  131. # Set CONFIG_STATUS to a null value if cxref-cpp is to be built.
  132.  
  133. End-Of-Configuration-Status
  134.  
  135. if [ $ok_gcc = yes ]; then
  136.     echo CONFIG_STATUS = >> Makefile.cpp
  137. else
  138.     echo CONFIG_STATUS = \'Configuration Failed\' >> Makefile.cpp
  139. fi
  140.  
  141.  
  142. # Tidy up at the end.
  143.  
  144. if [ $ok_gcc = yes ]; then
  145.     rm /tmp/config-cpp.$$
  146. else
  147.     echo ''
  148.     echo You will need to configure cxref-cpp by hand if you want to use it.
  149.     echo Read cpp/README file for help and edit cpp/Makefile.cpp yourself.
  150.     echo Meanwhile the build of cxref can continue without cxref-cpp.
  151.     exit 1
  152. fi
  153.